using System;
using Exchange.Export.DataHandler;

namespace Exchange.Export.DataHandler.Helper
{
	/// <summary>
	/// Summary description for convertRecurrencyPattern.
	/// </summary>
	public class convertRecurrencyPattern
	{
		const int recurrentDaily =  0x0A;
		const int recurrentWeekly = 0x0B;
		const int recurrentMonthly = 0x0C;
		const int recurrentYearly = 0x0D;
		const int recdailyEveryNDays = 0;
		const int recdailyEveryWeekday = 1;
		const int recweeklyEveryNWeeks = 1;
		const int recweeklyEveryNWeeksRegenerating = 0;
		const int recmonthlyEveryNMonths = 2;
		const int recmonthlyEveryNMonthsOnXth = 3;
		const int recyearlyOnDayD = 2;
		const int recyearlyOnTheXth = 3;
		public convertRecurrencyPattern()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		
		//this interface will change string is used only on testing purposes...
		//tempSubjectu is used only for test purposes to eas up mapping witch message we are talking about...

		public recurrence getRecurrencePattern (Exporter.RecurrenctInfo  ri, string tempSubject, ref DateTime endDateAndTime)
		{
			decodeRecurrencyData decodeRD = new decodeRecurrencyData();
			int [] tempArray = ri.array;
			int subType = tempArray[6];
			int recurrencyType =  tempArray[4].GetHashCode();
			
			recurrence re = new recurrence();
#if DEBUG			
			Console.WriteLine(tempSubject);
#endif
			switch (recurrencyType)
			{
				case recurrentDaily:
					decodeRD.DecodeDailyRecurrence(tempArray, ref re, ref endDateAndTime);
					break;
				case recurrentWeekly:

					decodeRD.DecodeWeeklyRecurrence(tempArray,ref re, ref endDateAndTime);
					break;
				case recurrentMonthly:
					decodeRD.DecodeMonthlyRecurrence(tempArray, ref re, ref endDateAndTime);
					break;
				case recurrentYearly:
					decodeRD.DecodeYearlyRecurrence(tempArray, ref re, ref endDateAndTime);
					break;
			}
			return(re);
		}
	}
}
